package com.yq.reggie.common;

import com.yq.reggie.controller.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 */
@Slf4j
/*@RestControllerAdvice*/
public class ProjectExceptionAdvice {
    @ExceptionHandler(RuntimeException.class)
    public Result exception(RuntimeException e){
        log.info("未知异常: {}",e.getMessage());
        return Result.fail("添加失败，请稍后在试");
    }
    @ExceptionHandler(BusinessException.class)
    public Result businessException(BusinessException e){
        log.info("业务异常：{}",e);
        return Result.fail(e.getMessage());
    }
}
